package org.bot.plugin.web.event;

import org.bot.api.event.DataStorage;
import org.bot.api.event.EventName;
import org.bot.api.event.Events;
import org.bot.api.flow.FlowNode;
import org.bot.plugin.web.util.WebApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 沧月
 * @create 0012 2023/10/12 13:01
 * @description <设置富文本框值>
 */
@Component
@EventName("设置富文本框值")
public class WebSetEduiEditorValue implements Events {

    @Autowired
    WebApi webApi;

    @Override
    public Object exec(FlowNode note, DataStorage data) {
        String script = "var editor = UE.getEditor('" + note.getArg() + "').setContent(arguments[0]);";
        return webApi.script(webApi.getWebDriver(note), script, data.get(note.getDataIndex()));
    }
}
